import Vue from "vue";
import Router from "vue-router";


Vue.use(Router);



// 公共路由
export const constantRoutes = [
  {
    path: "/",
    component: () => import("@/views/Home"),
    name: "home",
    meta: { title: "首页" },
  },
  {
    path: "/login",
    component: () => import("@/views/login"),
    name: "login",
    meta: { title: "登录" },
  },
  {
    path: "/news",
    component: () => import("@/views/news"),
    name: "news",
    meta: { title: "新闻" },
  },
  {
    path: "/newsDetail",
    component: () => import("@/views/newsDetail"),
    name: "newsDetail",
    meta: { title: "新闻详情" },
  },
  {
    path: "/information",
    component: () => import("@/views/information"),
    name: "information",
    meta: { title: "资料" },
  },
  {
    path: "/skill",
    component: () => import("@/views/skill"),
    name: "skill",
    meta: { title: "职业技能" },
  },
  {
    path: "/exam",
    component: () => import("@/views/exam"),
    name: "exam",
    meta: { title: "考试指南" },
  },
  {
    path: "/wurenji",
    component: () => import("@/views/wurenji"),
    name: "wurenji",
    meta: { title: "无人机" },
  },
  {
    path: "/order",
    component: () => import("@/views/order"),
    name: "order",
    meta: { title: "订单" },
  },
  {
    path: "/purchase",
    component: () => import("@/views/purchase"),
    name: "purchase",
    meta: { title: "购买" },
  },
  {
    path: "/start",
    component: () => import("@/views/start"),
    name: "start",
    meta: { title: "开始学习" },
  },
  {
    path: "/examination",
    component: () => import("@/views/examination"),
    name: "examination",
    meta: { title: "考试" },
  },
  {
    path: "/low",
    component: () => import("@/views/low"),
    name: "low",
    meta: { title: "低空应用" },
  },
  {
    path: "/questionBank",
    component: () => import("@/views/questionBank"),
    name: "questionBank",
    meta: { title: "题库" },
  },
  {
    path: "/vocationalSkills",
    component: () => import("@/views/VocationalSkills"),
    name: "vocationalSkills",
    meta: { title: "职业技能" },
  },
  {
    path: "/classDetail",
    component: () => import("@/views/classDetail"),
    name: "classDetail",
    meta: { title: "课程详情" },
  },
  {
    path: "/zuoti",
    component: () => import("@/views/zuoti"),
    name: "zuoti",
    meta: { title: "做题" },
  },
  {
    path: "/jiaojuan",
    component: () => import("@/views/jiaojuan"),
    name: "jiaojuan",
    meta: { title: "交卷" },
  },
  {
    path: "/zhifu",
    component: () => import("@/views/zhifu"),
    name: "zhifu",
    meta: { title: "支付" },
  },
  {
    path: "/tuikuan",
    component: () => import("@/views/tuikuan"),
    name: "tuikuan",
    meta: { title: "退款" },
  },
  {
    path: "/lianxifangshi",
    component: () => import("@/views/lianxifangshi"),
    name: "lianxifangshi",
    meta: { title: "联系方式" },
  },
];

// 防止连续点击多次路由报错
let routerPush = Router.prototype.push;
Router.prototype.push = function push (location) {
  return routerPush.call(this, location).catch((err) => err);
};

export default new Router({
  mode: "history", // 去掉url中的#
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes,
});
